<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!--<a-button @click="handleAdd" type="primary" icon="plus"  v-has="'CommonConfigList:add'">新增</a-button>-->
    </div>

    <!-- table区域-begin -->
    <div>
      <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <div slot="filterDropdown">
                    
          <a-card>         
            <a-checkbox-group @change="onColSettingsChange"  v-model="settingColumns"  :defaultValue="settingColumns">              
              <a-row>                
                <template v-for="item in defColumns">                  
                  <template v-if="item.key != 'rowIndex' && item.dataIndex != 'action'">                    
                    <a-col :span="6"  :key="item.key">
                      <a-checkbox :value="item.dataIndex">
                        {{ item.title }}
                      </a-checkbox>
                    </a-col>                  
                  </template>                
                </template>             
              </a-row>            
            </a-checkbox-group>
                      
          </a-card>
                  
        </div>
                
        <a-icon slot="filterIcon"  type="setting"  :style="{ fontSize: '16px', color: '#fff' }"  />
        <template slot="enableSingleDeviceLogin" slot-scope="text">
          {{text=='no'?'不启用':'启用'}}
        </template>
        <template slot="apkDownloadUrl" slot-scope="text">
         <j-ellipsis :value="text" :lenth="20"></j-ellipsis>
        </template>
        <template slot="fileViewUrl" slot-scope="text">
          <j-ellipsis :value="text" :lenth="20"></j-ellipsis>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" v-has="'CommonConfigList:edit'">编辑</a>
        </span>

      </a-table>
    </div>

    <commonConfig-modal ref="modalForm" @ok="modalFormOk"></commonConfig-modal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import CommonConfigModal from './modules/CommonConfigModal'
  import JEllipsis from '@/components/jeecg/JEllipsis';

  export default {
    name: 'CommonConfigList',
    mixins: [JeecgListMixin],
    components: {
      JEllipsis,
      CommonConfigModal
    },
    data() {
      return {
        description: '系统通用配置管理页面',
        // 表头
        settingColumns: [],
        columns: [],
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '启用单设备登录',
            align: 'center',
            dataIndex: 'enableSingleDeviceLogin',
            scopedSlots:{customRender:'enableSingleDeviceLogin'}
          },
          {
            title: '总经理银行卡号',
            align: 'center',
            dataIndex: 'bossBankNumber'
          },
          {
            title: '总经理银行卡类型',
            align: 'center',
            dataIndex: 'bossBankType'
          },
          {
            title: '总经理邮箱',
            align: 'center',
            dataIndex: 'bossEmail'
          },
          {
            title: '数据库备份邮箱',
            align: 'center',
            dataIndex: 'mysqlBackEmail'
          },
          {
            title: '总经理登录名',
            align: 'center',
            dataIndex: 'boosUsername'
          },
          {
            title: 'apk下载地址',
            align: 'center',
            dataIndex: 'apkDownloadUrl',
            scopedSlots:{customRender:'apkDownloadUrl'}
          },
          {
            title: '文件预览地址',
            align: 'center',
            dataIndex: 'fileViewUrl',
            scopedSlots:{customRender:'fileViewUrl'}
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              filterDropdown: 'filterDropdown', // 新增筛选插槽
              filterIcon: 'filterIcon', // 新增图标插槽
              customRender: 'action' // 原操作列插槽
            }
          }
        ],
        url: {
          list: '/commonconfig/commonConfig/list',
          delete: '/commonconfig/commonConfig/delete',
          deleteBatch: '/commonconfig/commonConfig/deleteBatch',
          exportXlsUrl: '/commonconfig/commonConfig/exportXls',
          importExcelUrl: 'commonconfig/commonConfig/importExcel'
        },
        dictOptions: {}

      }
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      }
    },
    methods: {
      initDictConfig() {
      }

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>